<template>
  <div>
    <el-container style="border: 1px solid #eee">
      <el-main>
        <el-form
          :inline="true"
          :model="formInline"
          class="demo-form-inline"
          label-position="left"
        >
          <el-row :gutter="20">
            <el-col :span="6">
              <el-form-item label="商品编码:">
                <el-input
                  v-model="formInline.skuId"
                  placeholder="商品编码"
                  maxlength="11"
                  type="text"
                  clearable
                ></el-input>
              </el-form-item>

              <el-form-item label="开始日期:">
                <div class="block">
                  <el-date-picker
                    v-model="formInline.startDate"
                    :picker-options="pickerOptions"
                    align="right"
                    type="date"
                    placeholder="开始日期:"
                  >
                  </el-date-picker>
                </div>
              </el-form-item>
            </el-col>
            <el-col :span="6">
              <el-form-item label="商品名称:">
                <el-input
                  v-model="formInline.skuName"
                  placeholder="商品名称"
                ></el-input>
              </el-form-item>

              <el-form-item label="结束日期:">
                <div class="block">
                  <el-date-picker
                    v-model="formInline.endDate"
                    :picker-options="pickerOptions"
                    align="right"
                    type="date"
                    placeholder="结束日期:"
                  >
                  </el-date-picker>
                </div>
              </el-form-item>
            </el-col>
            <el-col :span="6">
              <el-form-item label=" 审批人:">
                <el-input
                  v-model="formInline.user"
                  placeholder="审批人"
                ></el-input>
              </el-form-item>

              <el-form-item label="审批状态:">
                <el-select
                  v-model="formInline.status"
                  clearable
                  placeholder="请选择"
                >
                  <el-option
                    v-for="item in statusOptions"
                    :key="item.value"
                    :label="item.label"
                    :value="item.value"
                  >
                  </el-option>
                </el-select>
              </el-form-item>
            </el-col>
            <el-col :span="6">
              <el-form-item label="活动区域:">
                <el-select v-model="formInline.region" placeholder="活动区域">
                  <el-option label="区域一" value="shanghai"></el-option>
                  <el-option label="区域二" value="beijing"></el-option>
                </el-select>
              </el-form-item>

              <el-form-item label="付费方式:">
                <el-switch
                  v-model="formInline.payType"
                  active-color="#13ce66"
                  inactive-color="#ff4949"
                  active-text="按月付费"
                  inactive-text="按年付费"
                >
                </el-switch>
              </el-form-item>
            </el-col>
            <el-col :span="6">
              <el-form-item>
                <el-button @click="onReset">重置</el-button>
                <el-button type="primary" @click="onSubmit">查询</el-button>
              </el-form-item>
            </el-col>
          </el-row>
        </el-form>

        <el-container>
          <el-row :gutter="6">
            <el-col :span="200">
              <el-button type="primary" icon="el-icon-edit" size="small"
                >功能按钮</el-button
              >
            </el-col>
            <el-col :span="200">
              <el-button type="primary" icon="el-icon-edit" size="small"
                >功能按钮</el-button
              >
            </el-col>
            <el-col :span="200">
              <el-button type="primary" icon="el-icon-edit" size="small"
                >功能按钮</el-button
              >
            </el-col>
          </el-row>
        </el-container>
        <el-table :data="tableData" border stripe current-row-key="id">
          <el-table-column type="selection" width="55"> </el-table-column>
          <el-table-column label="操作" width="340">
            <el-row :gutter="20">
              <el-col :span="200">
                <el-button
                  @click="onAdd"
                  type="primary"
                  icon="el-icon-edit"
                  size="small"
                  >新增</el-button
                >
              </el-col>
              <el-col :span="200">
                <el-button
                  @click="onModify"
                  type="danger"
                  icon="el-icon-edit"
                  size="small"
                  >修改</el-button
                >
              </el-col>
              <el-col :span="200">
                <el-button
                  @click="onDelete"
                  type="danger"
                  icon="el-icon-delete"
                  size="small"
                  >删除</el-button
                >
              </el-col>
            </el-row>
          </el-table-column>

          <el-table-column prop="id" label="ID" width="140"> </el-table-column>
          <el-table-column prop="date" label="日期" width="140">
          </el-table-column>
          <el-table-column prop="name" label="姓名" width="120">
          </el-table-column>
          <el-table-column prop="address" label="地址"> </el-table-column>
        </el-table>
      </el-main>
    </el-container>
  </div>
</template>

<script>
import HelloWorld from "../components/HelloWorld.vue";

export default {
  components: {
    HelloWorld,
  },
  data() {
    return {
      tableData: [],
      msg1: "这里是动态消息",
      formInline: {
        user: "",
        region: "",
        skuId: "",
        skuName: "",
        startDate: "",
        endDate: "",
        payType: "",
      },
      pickerOptions: {
        disabledDate(time) {
          return time.getTime() >= Date.now();
        },
      },
      statusOptions: [
        {
          label: "审批通过",
          value: 1,
        },
        {
          label: "驳回",
          value: 2,
        },
        {
          label: "待审批",
          value: 0,
        },
      ],
    };
  },
  mounted() {
    //this.onSubmit();
  },
  methods: {
    onSubmit: function () {
      this.$message("点击了提交查询按钮");
      let _this = this;
      this.$axios({
        method: "post",
        url: "/greeting2",
        data: {
          skuNo: _this.formInline.skuId,
          skuName: _this.formInline.skuName,
          startDate: _this.formInline.startDate,
          endDate: _this.formInline.endDate,
          status: _this.formInline.status,
        },
      })
        .then(function (response) {
          _this.tableData = response.data;
        })
        .catch(function (error) {
          console.log(error);
        });
    },
    onReset: function () {
      this.$message("点击了重置按钮");
    },
    onAdd: function () {
      this.$message("点击了onAdd按钮");
    },
    onDelete: function () {
      this.$message("点击了onDelete按钮");
    },
    onModify: function () {
      this.$message("点击了onModify按钮");
    },
  },
};
</script>

<style>
#app {
  font-family: Avenir, Helvetica, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-align: center;
  color: #2c3e50;
  margin-top: -10px;
}
</style>
